<?php
namespace App\Http\Controllers\Admin;
use App\Model\Reply;
use App\Model\Replys;
use Illuminate\Http\Request;
use App\Model\Feedback;
use App\Model\FeedbackImg;
use Session;
use Auth;
class FeedbackController extends BaseController
{
    /**
     * 问题反馈视图
     */
    public function index()
    {
        return view('Admin/feedback/index');
    }

    public function feedback()
    {
       $data =  Feedback::orderBy('id','desc')->paginate(15);
       if($data){
           return ['code'=>1,'data'=>$data];
       }
    }

    public function find(Request $request)
    {
        $fid = $request->input('fid');
        $data = FeedbackImg::where(['fid'=>$fid])->get()->toArray();
        if($data){
           return ['code'=>1,'data'=>$data];
        }
    }

    /**
     * 回复
     */
    public function reply(Request $request)
    {
        $data = $request->all();
        $res = Feedback::where(['id'=>$data['id']])->update(['status'=>1, 'answer' => $data['data']]);
        if($res){
            return ['code'=>'1','data'=>'回复成功'];
        }else{
            return ['code'=>0,'data'=>'回复失败'];
        }
    }

}